#ifndef WXSRESOURCE_H
#define WXSRESOURCE_H

#include "wxseditor.h"
#include "wxscodinglang.h"
#include "wxsresourcetree.h"
#include "wxsproject.h"

class wxsResource: public wxObject {
    DECLARE_CLASS( wxsResource )
  public:
    wxsResource( wxsProject* Owner, const wxString& ResourceType, const wxString& GUI );
    virtual ~wxsResource();
    inline const wxString& GetResourceType() { return m_ResourceType; }
    inline const wxString& GetGUI() { return m_GUI; }
    inline wxsCodingLang GetLanguage() { return m_Language; }
    inline void SetLanguage( wxsCodingLang Lang ) { m_Language = Lang; }
    inline const wxString& GetResourceName() { return m_ResourceName; }
    inline void SetResourceName( const wxString& NewName ) { m_ResourceName = NewName; }
    void EditOpen();
    void EditClose();
    inline bool IsEditorOpened() { return M_Code_Editor != 0; }
    inline wxsEditor* GetEditor() { return M_Code_Editor; }
    inline const wxsResourceItemId& GetTreeItemId() { return m_TreeItemId; }
    void BuildTreeEntry( const wxsResourceItemId& Parent );
    inline wxString GetDeclarationFile() { return OnGetDeclarationFile(); }
    inline wxString GetAppBuildingCode() { return OnGetAppBuildingCode(); }
    bool ReadConfig( const TiXmlElement* Node );
    bool WriteConfig( TiXmlElement* Node );
    inline wxString GetProjectPath() { return m_Owner ? m_Owner->GetProjectPath() : _T( "" ); }
    inline wxsProject* GetProject() { return m_Owner; }
  inline bool DeleteCleanup( bool ShowDialog = true ) { return OnDeleteCleanup( ShowDialog ); }  protected:
    virtual wxsEditor* OnCreateEditor( wxWindow* Parent ) = 0;
    virtual bool OnReadConfig( const TiXmlElement* Node ) = 0;
    virtual bool OnWriteConfig( TiXmlElement* Node ) = 0;
    virtual bool OnCanHandleFile( const wxString& FileName ) = 0;
    virtual wxString OnGetDeclarationFile() { return wxEmptyString; }
    virtual wxString OnGetAppBuildingCode() { return wxEmptyString; }
    virtual int OnGetTreeIcon() { return -1; }
    virtual void OnFillPopupMenu( wxMenu* ) {}
    virtual bool OnPopupMenu( long ) { return false; }
  virtual bool OnDeleteCleanup( bool ) { return true; }  private:
    void EditorClosed();
    wxString m_ResourceType;
    wxString m_ResourceName;
    wxString m_GUI;
    wxsProject* m_Owner;
    wxsEditor* M_Code_Editor;
    wxsResourceItemId m_TreeItemId;
    wxsCodingLang m_Language;
    class wxsResourceRootTreeItemData;
    friend wxsEditor::~wxsEditor();
    friend class wxsProject;
    friend class wxsResourceRootTreeItemData;
};
#endif
